<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.ArrayList" %>
<%@page import="java.lang.String" %>
<%
    ArrayList<String[]> cats = (ArrayList<String[]>) request.getAttribute("categories");
    for (String[] cat : cats) {
        %><li><span id="<%=cat[0] %>"><%=cat[1] %></span><%
        ArrayList<String[]> subcats = (ArrayList<String[]>) request.getAttribute(cat[1]);
        if (!subcats.isEmpty())  {
        %><ul><%
            for (String[] subcat : subcats) {
        %><li id="<%=subcat[0] %>"><%=subcat[1] %></li><%
            }
        %></ul><%
        }
        %></li><%
    }
%>
